﻿@{var lstMenu = new List<BusinessLayer.WorldArtPrice.Models.AdminMenuExtend>();
    if (Session[BackEnd.Common.Constants.SessionKeys.UserInfo] != null)
    {

        var currentUser = Session[BackEnd.Common.Constants.SessionKeys.UserInfo].ToString();
        var menuBL = new BusinessLayer.WorldArtPrice.AdminMenuBL();
        //tam thoi fix getall de test
        lstMenu = menuBL.GetAdminMenuByUserName(currentUser);
        //return PartialView("MenuPartial", lstMenu);

    }
    if (lstMenu != null)
    {
        <ul>
            @{
            var rootMenu = lstMenu.Where(m => m.ParentID <= 0).OrderBy(t => t.OrderNo).ToList();
            }
            @foreach (var item in rootMenu)
            {
            
                <li>
                    <a href="@Url.Content(item.Url)">@item.Name</a>
                    @{
                        var subMenu = lstMenu.Where(m => m.ParentID == item.MenuID).OrderBy(t => t.OrderNo).ToList();
                        if (subMenu.Count > 0)
                        {
                            <ul>
                                @foreach (var subItem in subMenu)
                                {
            
                                    <li>
                                        @{
                                            if(!String.IsNullOrEmpty(subItem.Url)){
                                                <a href="@Url.Content(subItem.Url)">@subItem.Name</a>
                                            }
                                            else{
                                                <a href="#">@subItem.Name</a>
                                            }
                                                var inSubMenu = lstMenu.Where(s => s.ParentID == subItem.MenuID).OrderBy(t => t.OrderNo).ToList();
                                                if(inSubMenu.Count>0){
                                                 <ul>
                                                    @foreach (var inSubItem in inSubMenu)
                                                    {
            
                                                        <li>
                                                            @{
                                                                if (!String.IsNullOrEmpty(inSubItem.Url))
                                                                {
                                                                    <a href="@Url.Content(inSubItem.Url)">@inSubItem.Name</a>
                                                                }
                                                                else{
                                                                    <a href="#">@inSubItem.Name</a>
                                                                }
                               
                                                              }
                                                        </li>
                                                        }

                                                </ul>
                                                }
                                        }
                                        </li>
                                     }
                                </ul>
                        }
                      }

                </li>
            }
               
        </ul>
    }
 }

